package com.company;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.*;

public class User {


@Test
    public void add(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-config.xml");
        dataSource dataSource = applicationContext.getBean("dataSource",dataSource.class);
        Connection connection = dataSource.conn();

        String sql = "select * from b_good";
        try {
            PreparedStatement ps = connection.prepareStatement(sql);
            ResultSet statement = ps.executeQuery();
            while (statement.next()){
                System.out.println(statement.getString("good_name"));
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
